const router = require('koa-router')();
const sql = require('../database')

router.post('/api/users', async (ctx, next) => {
  const { name, age } = ctx.request.body
  await sql.insertData({ name, age }).then(res => {
    ctx.body = res
  })
})

router.get('/api/users', async (ctx, next) => {
  await sql.selectData().then(res => {
    ctx.body = res
  })
})

module.exports = router